
package com.airplane.hotdiscuss.lyric;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.os.Environment;
import android.provider.ContactsContract.CommonDataKinds.Event;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.SlidingDrawer;

public class LyricSlidingDrawer extends SlidingDrawer {
    private static final String TAG = SlidingDrawer.class.getSimpleName();

    private int a = 0;
    private boolean b;

    public LyricSlidingDrawer(Context paramContext, AttributeSet paramAttributeSet) {
        this(paramContext, paramAttributeSet, 0);
    }

    public LyricSlidingDrawer(Context paramContext, AttributeSet paramAttributeSet, int paramInt) {
        super(paramContext, paramAttributeSet, paramInt);
    }

    @Override
    protected void dispatchDraw(Canvas canvas) {
        Log.d(TAG, "dispatchDraw() ...");
        /*
        super.dispatchDraw(canvas);
        long drawingTime = getDrawingTime();
        View handleView = super.getHandle();
        View contentView = super.getContent();
        boolean bool1 = drawChild(canvas, handleView, drawingTime);
        float dx = 0.0f;
        float dy = 0.0f;

        if (super.isMoving()) {
            canvas.save();
            if (b) {
                dx = handleView.getTop() - a;
                canvas.translate(dx, dy);
                drawChild(canvas, contentView, drawingTime);
                canvas.restore();
            }
        }*/
        long time = getDrawingTime();
        View handle = super.getHandle();
        View content = super.getContent();
        drawChild(canvas, handle, time);
        if (!this.isOpened() || this.isMoving()) {
            canvas.save();
            float f2 = (handle.getTop() - this.getTop()) / 2;
            Log.d(TAG, "handle.getTop() :" + handle.getTop());
            Log.d(TAG, "this.getTop() :" + this.getTop());
            Log.d(TAG, "handle.getBottom() :" + handle.getBottom());
            Log.d(TAG, "this.getBottom() :" + this.getBottom());
            Log.d(TAG, "f2 :" + f2);

            canvas.clipRect(this.getLeft(), handle.getBottom(),
                    this.getRight(), this.getBottom());
            canvas.translate(0, f2);
            drawChild(canvas, content, time);
            canvas.restore();
        } else {
            super.dispatchDraw(canvas);
        }
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == Event.OFFLINE) {
            int i = super.getHandle().getBottom();
            int j = (int)event.getY();

            if (j > i) {
                int k = i+20;
                if (j <= k) {
                    animateToggle();
                }
            }
        }
        return super.onTouchEvent(event);
    }
}
